package com.xinnet.mms.customtransfer.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xinnet.mms.customerManage.dao.CustomerManageDao;
import com.xinnet.mms.customercare.dao.CustomerCareDao;
import com.xinnet.mms.customtransfer.service.CustomSystematizationService;
import com.xinnet.mms.customtransfer.service.OpenSeaCustomTransferService;
import com.xinnet.mms.customtransfer.service.TransferRuleService;
import com.xinnet.mms.entity.Customer;
import com.xinnet.mms.entity.Product;
import com.xinnet.mms.utils.CustomerType;
@Service("openSeaCustomTransferService")
public class OpenSeaCustomTransferServiceImpl implements OpenSeaCustomTransferService{
	@Autowired
	CustomerCareDao  customerCareDao;
	@Autowired
	CustomerManageDao customerManageDao;
	@Autowired
	TransferRuleService transferRuleService;
	@Autowired
	CustomSystematizationService customSystematizationService;
	/**
	 * 公海客户流转
	 * @throws Exception 
	 */
	@Override
	public void openSeaCustomTransfer() throws Exception {/*
		List<Product> transferRuleList = transferRuleService.getTransferRule();
		if(transferRuleList==null || transferRuleList.isEmpty()){
			return;
		}
		Map<Integer,List<Customer>> customerMap = customSystematizationService.customSystematization();
		if(customerMap==null || customerMap.isEmpty()){
			return;
		}
		List<Customer> openSeaCustomList = customerMap.get(CustomerType.OPEN_SEA_CUSTOMER);
		if(openSeaCustomList==null || openSeaCustomList.isEmpty()){
			return;
		}
		List<String> customerCareCustomIdList = customerCareDao.getCustomerCareCustomerIdList();
		if(customerCareCustomIdList==null || customerCareCustomIdList.isEmpty()){
			return;
		}
		List<String> ofServiceCustomIdList=new ArrayList<String>();
		for (Iterator<Customer> iterator = openSeaCustomList.iterator(); iterator.hasNext();) {
			Customer customer = (Customer) iterator.next();
			String customId = customer.getCusId();
			boolean isOfService=false;
			for (Iterator<String> iterator2 = customerCareCustomIdList.iterator(); iterator2.hasNext();) {
				String tempCustomId = (String) iterator2.next();
				if(tempCustomId.equals(customId)){
					isOfService=true;
					break;
				}
			}
			if(isOfService){
				ofServiceCustomIdList.add(customId);	
			}	
		}
		if(ofServiceCustomIdList.size()>0){
			customerManageDao.batchUpateOpenSeaCustom(ofServiceCustomIdList);
		}	
	*/}
}
